package com.heraleign.mybatis.mapper;

import com.heraleign.mybatis.bean.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 通过注解的方式编写
 */
//@Mapper
public interface StudentMapper {
    @Select("select * from student")
    List<Student> selectList();

    @Select("select * from student where id=#{id}")
    Student selectById(Integer id);

    @Select("select * from student where stu_name=#{stuName}")
    Student queryStudentByStuName(String stuName);

    @Insert("insert into student(stu_code,stu_name,age,grade,classes,address) values(#{stuCode},#{stuName},#{age},#{grade},#{classes},#{address})")
    int save(Student student);

    @Update("update student set address=#{address},age=#{age} where id=#{id}")
    int update(Student student);

    @Delete("delete from student where id=#{id}")
    int delete(Integer id);

}
